/*
 * @(#)AbstractRuleAction.java
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of DCIVision
 * Ltd ("Confidential Information").  You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms of the license
 * agreement you entered into with DCIVision Ltd.
 */
package com.dcivision.rules.action;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.mandarax.eca.ActionException;

import com.dcivision.framework.SessionContainer;
import com.dcivision.user.bean.UserRecord;

/**
 * <p>Class Name:  AbstractRuleAction </p>
 * <p>Description: This class implements the RuleAction. </p> 
 * 
 * @see org.mandarax.eca.Action
 * @author       Tony Chen
 * @company      DCIVision Limited
 * @creationdate 12/08/2005
 * @version      $Revision: 1.3 $
 * 
 */
public abstract class AbstractRuleAction implements RuleAction {
  protected Log log = LogFactory.getLog(this.getClass().getName());

  private Object target = null;   
  
  private String ruleName = null; 
  /**
   * Returns the target.
   * @return Object
   */
  public Object getTarget() {
    return target;
  }

  /**
   * Sets the target.
   * @param target The target to set
   */
  public void setTarget(Object target) {
    this.target = target;
  }
  
  public abstract void perform(Object[] param) throws ActionException;
  
  /**
   * @return SessionContainer The new SessionContainer at this moment, will evaluate again on what should return
   */
  public SessionContainer getSessionContainer() {
    SessionContainer sessionCon = new SessionContainer();
   
    UserRecord tmpUserRecord = new UserRecord();
    tmpUserRecord.setID(new Integer(0));
    sessionCon.setUserRecord(tmpUserRecord);
    sessionCon.setUserIPAddress("127.0.0.1");
    
    return sessionCon;
  }
  
  public String toString(){
    return this.getClass().getName() + "(" + this.getTarget() + ")";
  }

  public String getRuleName() {
    return ruleName;
  }

  public void setRuleName(String ruleName) {
    this.ruleName = ruleName;
  }
}
